home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Tool Chest / Development Tools & Languages / HyperCard Related / APDA HyperCard Toolkits / HyperCard CTB Toolkit 1.0b2 / Source Code / CTBConfigure.p < prev    next >
Encoding:
Text File  |  1995-02-07  |  2.6 KB  |  99 lines  |  [TEXT/MPS ]

  1. (*
  2.     CTBConfigure parameters[,type] -- Configure a tool. The type parameter tells which type of
  3.         tool ("connection", "terminal", or "file transfer") to configure; if that parameter is missing
  4.         or empty, then it defaults to "connection". The parameters parameter is a string to be passed to
  5.         tool to configure it. The specific details of the string contents varies depending upon the
  6.         type of tool.
  7.  
  8.     To compile and link this file using Macintosh Programmer's Workshop,
  9.  
  10.         pascal -w CTBConfigure.p
  11.         link -m ENTRYPOINT -o HyperCommands -rt XCMD=2750 -sn Main=CTBConfigure ∂
  12.             CTBConfigure.p.o "{MPW}"Libraries:interface.o "{MPW}"Libraries:Libraries:HyperXLib.o
  13.  
  14.     © Copyright 1990 by Apple Computer, Inc.
  15.  
  16.     Initial coding 2/90 by Harry R. Chesley.
  17. *)
  18.  
  19. {$R-}
  20.  
  21. {$S CTBConfigure }     { Segment name must be the same as the command name. }
  22.  
  23. unit DummyUnit;
  24.  
  25. interface
  26.  
  27. uses MemTypes, QuickDraw, OSIntf, ToolIntf, CTBUtils, FTIntf, CMIntf, TMIntf, CRMIntf, HyperXCmd;
  28.  
  29. procedure EntryPoint(paramPtr: XCmdPtr);
  30.     
  31. implementation
  32.  
  33. procedure CTBConfigure(paramPtr: XCmdPtr); forward;
  34.  
  35. procedure EntryPoint(paramPtr: XCmdPtr);
  36.  
  37.     begin
  38.         CTBConfigure(paramPtr);
  39.     end;
  40.  
  41. procedure CTBConfigure(paramPtr: XCmdPtr);
  42.  
  43.     {$I CTBUtil.inc}
  44.  
  45.     var i: integer;
  46.         paramStringHandle: Handle;
  47.         tt: ToolType;
  48.         result: integer;
  49.         s: Str255;
  50.         s2: Str32;
  51.  
  52.     procedure Fail(errMsg: Str255); { set theResult and quit }
  53.         begin
  54.             paramPtr^.returnValue := PasToZero(paramPtr,errMsg);
  55.             exit(CTBConfigure);
  56.         end;
  57.  
  58.     begin
  59.         { Verify the number of parameters. }
  60.         i := paramPtr^.paramCount;
  61.         if (i = 0) or (i > 2) then Fail('Invalid parameter count');
  62.  
  63.         { Make sure the Comm Toolbox is present and ready. }
  64.         CTBReady;
  65.  
  66.         { Get the configuration string. }
  67.         paramStringHandle := paramPtr^.params[1];
  68.         HLock(paramStringHandle);
  69.         { Get the tool type to configure. }
  70.         if i = 1 then tt := connectionTool
  71.         else tt := GetToolTypeParm(2);
  72.         { Configure... }
  73.         case tt of
  74.             connectionTool: result := CMSetConfig(Globals^^.connHand,paramStringHandle^);
  75.             fileTransferTool: result := FTSetConfig(Globals^^.FTHand,paramStringHandle^);
  76.             terminalTool: result := TMSetConfig(Globals^^.termHand,paramStringHandle^);
  77.             end;
  78.         HUnlock(paramStringHandle);
  79.  
  80.         { If we got an error, report it in a relatively meaningful way. }
  81.         if result <> noErr then
  82.             begin
  83.                 if result = -1 then
  84.                     begin
  85.                         s := 'Unknown error';
  86.                         s2 := '';
  87.                     end
  88.                 else
  89.                     begin
  90.                         LongToStr(paramPtr,result,s);
  91.                         if result < 0 then s := 'OS error: '
  92.                         else s := 'Parse failed at position: '
  93.                     end;
  94.                 Fail(Concat(Concat('Failure during configuration: ',s),s2));
  95.             end;
  96.     end;
  97.  
  98. end.
  99.